#ifndef _H_SAMPLER_NAIVE
#define _H_SAMPLER_NAIVE
#include "../core/sampler.hpp"
#include "../core/geometry.hpp"
#include <random>
namespace chen {
class NaiveSampler: public Sampler {
private:
    std::mt19937 rng;
    unsigned mnv, mxv;
public:
    inline NaiveSampler (int sd = -1) {
        if(sd == -1) {
            std::random_device rd;
            sd = rd();
        }
        rng.seed(sd);
        mnv = rng.min();
        mxv = rng.max();
    }
    inline void nextSample () {
        // do nothing
    }
    inline Sampler * clone (unsigned nseed) {
        NaiveSampler * ret = new NaiveSampler(nseed);
        return ret;
    }
    inline Float gen () {
        return min((Float)(rng()-mnv)/(mxv-mnv), float_one_minus);
    }
    inline Point2 gen2D () {
        return Point2(gen(), gen());
    }
    inline Float* genArray (int n) {
        Float * arr = new Float[n];
        for(int i = 0; i<n; i++)
            arr[i] = gen();
        return arr;
    }
    inline Point2* gen2DArray (int n) {
        Point2 * arr = new Point2[n];
        for(int i = 0; i<n; i++)
            arr[i] = gen2D();
        return arr;
    }
    inline void setSampleIndex (int i) {
        unused(i);
    }
    ~NaiveSampler() {}
};
}
#endif